#include "clientmonitor.h"
#include "netparam.h"
ClientMonitor::ClientMonitor(int port,QObject *parent):QTcpServer(parent)
{
   if(!listen(QHostAddress::Any,port))
       emit notify(QString(),NetError::CLIENT_LISTEN_FAIL);// clientmonitor can't listen on the port
    qDebug("client monitor setup");
}
void ClientMonitor::incomingConnection(int socketDescriptor)
{

    Connection *connection = new Connection(this);
    connection->setSocketDescriptor(socketDescriptor);
    connection->ipTo = connection->peerAddress().toString();
    qDebug("in monitor,get a connection from ip:%s",connection->ipTo.toAscii().data());
    emit newConnection(connection);
}
